package com.rigsofrods.truckeditor.app;

import java.io.File;

import javax.swing.filechooser.FileFilter;

public class RoRVehicleFilter extends FileFilter {
	private static final String DESCRIPTION = "RoR vehicle files";
	private static final String TRUCK = "truck";
	private static final String LOAD = "load";
	private static final String TRAILER = "trailer";
	private static final String PLANE = "plane";
	private static final String BOAT = "boat";
	private static final String TRAIN = "train";

	@Override
	public boolean accept(File f) {
	    if (f.isDirectory()) {
	        return true;
	    }

	    String extension = FileUtils.getExtension(f);
	    if (extension != null) {
	        if (extension.equals(TRUCK) ||
	            extension.equals(TRAILER) ||
	            extension.equals(LOAD) ||
	            extension.equals(BOAT) ||
	            extension.equals(PLANE) ||
	            extension.equals(TRAIN)) {
	                return true;
	        } else {
	            return false;
	        }
	    }

	    return false;
	}

	@Override
	public String getDescription() {
		return DESCRIPTION;
	}
	
}